package com.info.widgets.Contact;

import java.util.ArrayList;
import java.util.List;
import java.sql.*;

import com.info.widgets.ConnectionHelper;
import com.info.widgets.DAOException;
import com.info.widgets.Contact.Contact;

public class ContactService {

	public ArrayList<Contact> contactusCreation(Contact contactus) throws DAOException {
		
		Contact contact=new Contact(); 
		Connection con=null;
		String dbtime=null;
		//String query="select *FROM Mycaspian.contact_us";
		ArrayList<Contact> arrayList=new ArrayList<Contact>();
		try{
			con=ConnectionHelper.getConnection();
			Statement stmt= con.createStatement();
			//Resultset rs=stmt.executeQuery(query);
			PreparedStatement pst=null;
			pst=con.prepareStatement("INSERT INTO mycaspian.contact_us(first_name,last_name,organisation, email_id, phone_number, address, country, state, city, comments, captcha_code, zip, id) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ");
			
			
System.out.println("contactusCreation ***"+contactus.getFirstName());
			
			pst.setString(2,contactus.getLastName());
			pst.setString(3,contactus.getOrganisation());
			pst.setString(4,contactus.getEmailid());
			pst.setLong(5, contactus.getPhone());
			pst.setString(6,contactus.getAddress());
			pst.setString(2,contactus.getState());
			pst.setString(3,contactus.getCity());
			pst.setString(4,contactus.getComments());
			pst.setLong(5, contactus.getZip());
			pst.setLong(6,contactus.getId());
			
			
			pst.executeUpdate();
			
			
		} catch (Exception e) {
			e.printStackTrace();
			} finally {
				ConnectionHelper.close(con);
			}
		return arrayList;
		
		
	}
}